/*
 * @Author: your name
 * @Date: 2021-07-07 15:01:29
 * @LastEditTime: 2022-09-07 16:03:48
 * @LastEditors: 11 11
 * @Description: In User Settings Edit
 * @FilePath: \exc-tl1-2\SRC\user_src\eeprom.h
 */
/**
 *文件名称：
 *
 *文件日期：
 *
 *文件描述：
 *
 *文件版本：V1.0
 *
 */

#ifndef EEPROM_H
#define EEPROM_H

/* 头文件包含区	*/
#include "protocol.h"
#include "init_config.h"
#include "com_pc.h"
#include "string.h"

/* 类型声明区 */
void data_flash_write(void);
void data_flash_read(uint16_t time_out);

/* 宏定义区 */
#define DEV_INFO_ADDR    0x08000000	// 0处
#define FLASH_OTA_ADDR   0x00010000	// 64K处
#define EEPROM0_IAP_ADDR 0x08001000 // 4K处
#define EEPROM1_IAP_ADDR 0x08003000 // 12K处
#define IP_REMAP_ADDR    0x08000800	// 2 K

#define ALARM_REMAP_ADDR 0x08000A00	// 2.5 K
#define LAMP_POWER       0x08000D00	// 3 K
#define POWER_OFF_ADDR       0x08000E00	// 3.1K

/* 函数声明区 */
uint16_t FlashRead(uint32_t addr);
uint8_t FlashWrite(uint32_t start_addr, uint16_t *pbuf, uint16_t plen);
u8 FlashErase(uint32_t addr, uint16_t page_num);
u8 eeprom_program(uint32_t dst_addr, uint32_t src_addr, uint32_t len);
u8 flash_program(uint32_t dst_addr, uint32_t src_addr, uint32_t len);
uint8_t FlashReadALL(uint32_t start_addr, uint16_t *pOutBuf, uint16_t OutBufLen);
uint8_t FlashReadALLU8(uint32_t start_addr, uint8_t *pOutBuf, uint16_t OutBufLen);
u8 eeprom_earse(uint32_t earse_addr, uint32_t len);
void IAP_APP_Jump(void);
void IAP_IAP_Jump(void);
void save_power_off_data(void);

#define P_SIZE 256
extern u8 p_flash_data[P_SIZE];



#endif
